package cn.edu.ujn.booksshop.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.ujn.booksshop.dao.Payment;
import cn.edu.ujn.booksshop.dao.PaymentMapper;
import cn.edu.ujn.util.Page;

@Service
@Transactional
public class PaymentServiceImpl implements IPaymentService {

	@Autowired
	private PaymentMapper paymentDao;

	@Override
	public Page<Payment> selectAll(Integer page, Integer rows) {
		// TODO Auto-generated method stub
		List<Payment> list = this.paymentDao.selectAll((page - 1) * rows, rows);
		Page<Payment> pages = new Page<Payment>();
		pages.setPage(page);
		pages.setRows(list);
		pages.setSize(rows);
		Integer count = this.paymentDao.selectCount();
		pages.setTotal(count);
		return pages;
		
	}

	@Override
	public int insert(Payment row) {
		// TODO Auto-generated method stub
		int insert = this.paymentDao.insert(row);
		return insert;
	}

	@Override
	public int deleteByPrimaryKey(Integer paymentid) {
		// TODO Auto-generated method stub
		int delete = this.paymentDao.deleteByPrimaryKey(paymentid);
		return delete;
	}

	@Override
	public int updateByPrimaryKeySelective(Payment row) {
		// TODO Auto-generated method stub
		int update = this.paymentDao.updateByPrimaryKeySelective(row);
		return update;
	}

	@Override
	public Payment getPaymentById(Integer id) {
		// TODO Auto-generated method stub
		Payment payment = this.paymentDao.selectByPrimaryKey(id);
		return payment;
	}

}
